//
//	 ______    ______    ______    
//	/\  __ \  /\  ___\  /\  ___\   
//	\ \  __<  \ \  __\_ \ \  __\_ 
//	 \ \_____\ \ \_____\ \ \_____\ 
//	  \/_____/  \/_____/  \/_____/ 
//
//	Powered by BeeFramework
//
//
//  MyLinksCell.m
//  Pizza
//
//  Created by ghwang on 15/6/17.
//  Copyright (c) 2015年 sendInfo. All rights reserved.
//

#import "MyLinksCell.h"

#pragma mark -

@implementation LinkItemCell

SUPPORT_AUTOMATIC_LAYOUT(YES)
SUPPORT_RESOURCE_LOADING(YES)

- (void)load
{
    
    
}
- (void)dataDidChanged
{
    $(@"info").DATA([NSString stringWithFormat:@"%@                         %@",self.data[0]?:@"",self.data[1]?:@""]);
    
}

@end

@implementation MyLinksCell

SUPPORT_AUTOMATIC_LAYOUT( YES )
SUPPORT_RESOURCE_LOADING( YES )

NSArray *tits;
- (void)load
{
    
    self.list.lineCount = 1;
    self.list.animationDuration = 0.2f;
    self.list.whenReloading = ^{
    
        self.list.total = 5;
        for (BeeUIScrollItem *item in self.list.items) {
            
            item.size = CGSizeMake(self.list.size.width, 50);
            if (self.data) {
                
 
                tits = @[@"一级连锁店",@"二级连锁店",@"三级连锁店",@"四级连锁店",@"五级连锁店"];

                item.data = @[[tits safeObjectAtIndex:item.index],[self.data safeObjectAtIndex:item.index]];

            }

            item.clazz = [LinkItemCell class];
        }
        
    
    };
    self.MSG(HttpAPI.shop_link).INPUT(@"body",@{@"token":[SendIFAPPDefault shareAppDefault].userToken});
}

- (void)unload
{
}

- (void)dataDidChanged
{
    // TODO: fill data
}

- (void)layoutDidFinish
{
    // TODO: custom layout here
}
ON_MESSAGE3(HttpAPI, shop_link, msg){

    if (msg.sending) {
        
        [self presentLoadingTips:@""];
        
    }else{
        
        [self dismissTips];
        
        if (msg.succeed) {
            
            Status *sta = msg.GET_OUTPUT(@"status");
            if ([sta.code intValue] != 10000) {
                
                [self presentMessageTips:sta.message];
                return;
            }
            NSDictionary *dic = msg.GET_OUTPUT(@"shopsDic");
            self.data =@[dic[@"link_shop1"],dic[@"link_shop2"],dic[@"link_shop3"],dic[@"link_shop4"],dic[@"link_shop5"],];
            [self.list asyncReloadData];
        }else{
            
            [self presentFailureTips:@"网络错误"];
            
        }
        
    }
    


}
@end
